package com.demo.pagers;


import com.demo.Finder;
import org.openqa.selenium.WebElement;

/**
 * Created by Aaron on 2017/7/2.
 */
public class PageLogin {
    private Finder finder;

    public PageLogin(Finder finder){
        this.finder = finder;
    }

   public WebElement getNameET(){
       return finder.findById("com.netease.newsreader.activity:id/op");
   }

    public WebElement getPWET(){
        return finder.findById("com.netease.newsreader.activity:id/ov");
    }

    public WebElement getLoginBtn(){
        return finder.findById("com.netease.newsreader.activity:id/ow");
    }

    public void enterName(String name){
        finder.enterText(getNameET(),name);
    }

    public void enterPwd(String pwd){
        finder.enterText(getPWET(),pwd);
    }

    public void clickLoginBtn(){
        getLoginBtn().click();
    }

    public void clearNameET(){
        finder.clear(getNameET());
    }

    public void clearPwdET(){
        finder.clear(getPWET());
    }

    public void login(String name,String pwd){
        clearNameET();
        enterName(name);
        getPWET().click();
        enterPwd(pwd);
        clickLoginBtn();
    }

}
